//
//  CurrentAllocationViewController.m
//  TraineeManagementSystem
//
//  Created by Dhanashree Bodas on 30/01/15.
//  Copyright (c) 2015 Dhanashree Bodas. All rights reserved.
//

#import "CurrentAllocationViewController.h"

@interface CurrentAllocationViewController ()
{
    
}
@end

@implementation CurrentAllocationViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self loadData];
        // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(void)loadData
{
    TraineeCourseTable *tc=[[TraineeCourseTable alloc] init];
    self.adata=[tc getAllocations:_tid];
    [self.allocatedTblview reloadData];
    
    if(_adata.count == 0)
    {
        UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"Validation" message:@"There are no accepted courses" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:nil, nil];
        
        [alert show];
        
        
    }
}

- (IBAction)backPressed:(id)sender {
    [self dismissViewControllerAnimated:YES completion:nil];
}

//- (void)viewWillAppear:(BOOL)animated
//{
//    [self loadData];
//    [self.allocatedTblview reloadData];
//    
//}


- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.adata.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];
    
    
    NSString *coursename=[[self.adata objectAtIndex:indexPath.row] objectAtIndex:0];
    cell.textLabel.text=coursename;
    cell.detailTextLabel.text=@"Accepted";

    return cell;
    
    
}

@end
